package com.lbs.jiepiaisi.utils;

import android.content.Context;

import com.lbs.jiepiaisi.R;
import com.lbs.jiepiaisi.view.LoadingDialog;

/**
 * Created by yu on 2019-12-20 13:28.
 * Description:
 */
public class DialogUtil {

    private static LoadingDialog dialog;

    public static void setContent(String title) {
        if (dialog == null) throw new NullPointerException("dialog == null");
        dialog.setContent(title);
    }

    public static void show(Context context) {
        if (dialog == null) {
            dialog = new LoadingDialog(context, R.style.LoadingDialog);
            try {
                dialog.show();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void show(Context context, String title) {
        if (dialog == null) {
            dialog = new LoadingDialog(context, R.style.LoadingDialog);
            try {
                dialog.show(title);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void dismiss() {
        if (dialog != null) {
            try {
                dialog.dismiss();
                dialog = null;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
